package com.tdkj.model.shop;

import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.tdkj.model.base.BaseEntity;
import com.tdkj.model.decorate.BeanDecorate;
import com.tdkj.model.decorate.BeanLayout;
import com.tdkj.model.decorate.BeanLayoutModuleConfig;
import com.tdkj.model.decorate.BeanStyle;

/**
 * 
 */
@Entity
@Table(name = "shop_decorate_info")
public class BeanShopDecorateInfo extends BaseEntity {

	private BeanShop shop;
	
	private BeanLayout layout;
	
	private BeanStyle style;
	
	private List<BeanDecorate> decorates;
	
	private Map<BeanLayout,BeanLayoutModuleConfig> configs;

	@OneToOne(fetch=FetchType.LAZY, cascade={CascadeType.REFRESH}, mappedBy="decorateInfo")
	public BeanShop getShop() {
		return shop;
	}

	public void setShop(BeanShop shop) {
		this.shop = shop;
	}

	@ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH})
	@JoinColumn(name="layout_id")
	public BeanLayout getLayout() {
		return layout;
	}

	public void setLayout(BeanLayout layout) {
		this.layout = layout;
	}

	@ManyToOne(fetch=FetchType.EAGER, cascade={CascadeType.REFRESH})
	@JoinColumn(name="style_id")
	public BeanStyle getStyle() {
		return style;
	}

	public void setStyle(BeanStyle style) {
		this.style = style;
	}

	@ManyToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL})
	@JoinTable(name="shop_decorate_info_to_decorate", joinColumns={@JoinColumn(name="info_id")},inverseJoinColumns={@JoinColumn(name="config_id")})
	public List<BeanDecorate> getDecorates() {
		return decorates;
	}

	public void setDecorates(List<BeanDecorate> decorates) {
		this.decorates = decorates;
	}

	
	@OneToMany(fetch=FetchType.EAGER, cascade={CascadeType.ALL})
	@JoinTable(name="shop_decorate_info_to_config", joinColumns={@JoinColumn(name="info_id")},inverseJoinColumns={@JoinColumn(name="config_id")})
	@MapKey(name="layout")
	public Map<BeanLayout,BeanLayoutModuleConfig> getConfigs() {
		return configs;
	}

	public void setConfigs(Map<BeanLayout,BeanLayoutModuleConfig> configs) {
		this.configs = configs;
	}

	
	
}